﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace ScriptZilla
{
    
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void languageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
        }

        private void assemblyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language= "asm";
            toolStripStatusLabel2.Text = "Assembly";


        }

        private void hTMLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "html";
            toolStripStatusLabel2.Text = "Hypertext Markup Language (HTML)";
        }

        private void microsoftFlavoredTSQLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "mssql";
            toolStripStatusLabel2.Text = "Microsoft Flavored T-SQL / MySQL";

        }

        private void javaScriptToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "js";
            toolStripStatusLabel2.Text = "JavaScript";
        }

        private void postgreSQLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "pssql";
            toolStripStatusLabel2.Text = "Postgre SQL";
        }

        private void pythonToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "python";
            toolStripStatusLabel2.Text = "Python";
        }

        private void vBScriptToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "vbscript";
            toolStripStatusLabel2.Text = "VBScript";
        }

        private void xMLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "xml";
            toolStripStatusLabel2.Text = "Extensible Markup Language (XML)";
        }

        private void adaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "ada";
            toolStripStatusLabel2.Text = "Ada Programming Language / Ada";

        }

        private void bashToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "bash";
            toolStripStatusLabel2.Text = "Bourne-Again shell (GNU / UNIX) / Bash";

        }

        private void batchToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "batch";
            toolStripStatusLabel2.Text = "Windows Batch / Batch";

        }

        private void cSSToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "css";
            toolStripStatusLabel2.Text = "Cascading Style Sheet / CSS";

        }

        private void sQLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "sql";
            toolStripStatusLabel2.Text = "SQL";

        }

        private void pureBasicToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "purebasic";
            toolStripStatusLabel2.Text = "Pure Basic";

        }

        private void rubyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "ruby";
            toolStripStatusLabel2.Text = "Ruby";

        }

        private void pascalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "pascal";
            toolStripStatusLabel2.Text = "Pascal Programming Lanugage / Pascal";

        }

        private void perlToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "perl";
            toolStripStatusLabel2.Text = "Perl";

        }

        private void pHPScriptToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "phpscript";
            toolStripStatusLabel2.Text = "PHPScript";

        }

        private void hypertextToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "hypertext";
            toolStripStatusLabel2.Text = "Hypertext";

        }

        private void innoSetupToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "innosetup";
            toolStripStatusLabel2.Text = "Inno Setup / ISS";

        }

        private void visualBasicToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "vbscript";
            toolStripStatusLabel2.Text = "Visual Basic / Visual Basic .NET";

        }

        private void fromFileIntoScriptToolStripMenuItem_Click(object sender, EventArgs e)
        {
            

            



        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFile.Filter = "Assembly Source File (*.asm)|*.asm|C# / CSharp Source File (*.cs)|*.cs|HTML-File (*.html)|*.html|JavaScript-File (*.js)|*.js|PostScript-File (*.ps)|*.ps|VBScript-File (*.vbs)|*.vbs|XML-File (*.xml)|*.xml|Ada Source File (*.ada)|*.ada|Windows-Batch-File (*.bat)|*.bat|CSS-File (*.css)|*.css|Ruby File (*.rb)|*.rb|Pascal Source File (*.pas)|*.pas|Perl Source File (*.pl)|*.pl|PHPScript-File (*.php)|*.php|Inno Setup Script (*.iss)|*.iss|Visual Basic Source File (*.vb)|*.vb|All Files (*.*)|*.*";
            if (openFile.ShowDialog() == DialogResult.OK)
            {
                StreamReader myFile = new StreamReader(openFile.FileName);
                String myString = myFile.ReadToEnd();
                scintilla1.Text = myString;
                this.Text = openFile.FileName + " - ScriptZilla";
                newScriptToolStripMenuItem.Text = openFile.FileName + " - ScriptZilla";




            }
        }

        private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.Text = "";
            this.Text = "NewScript - ScriptZilla";
            newScriptToolStripMenuItem.Text = "NewScript - ScriptZilla";

        }

        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
            saveFile.Filter = "Assembly Source File (*.asm)|*.asm|C# / CSharp Source File (*.cs)|*.cs|HTML-File (*.html)|*.html|JavaScript-File (*.js)|*.js|PostScript-File (*.ps)|*.ps|VBScript-File (*.vbs)|*.vbs|XML-File (*.xml)|*.xml|Ada Source File (*.ada)|*.ada|Windows-Batch-File (*.bat)|*.bat|CSS-File (*.css)|*.css|Ruby File (*.rb)|*.rb|Pascal Source File (*.pas)|*.pas|Perl Source File (*.pl)|*.pl|PHPScript-File (*.php)|*.php|Inno Setup Script (*.iss)|*.iss|Visual Basic Source File (*.vb)|*.vb|All Files (*.*)|*.*";
            if (saveFile.ShowDialog() == DialogResult.OK)
            {
                StreamWriter myWriter = new StreamWriter(saveFile.FileName);
                myWriter.Write(scintilla1.Text);
                myWriter.Close();
                this.Text = saveFile.FileName + " - ScriptZilla";
                newScriptToolStripMenuItem.Text = saveFile.FileName + " - ScriptZilla";

            }
        }

        private void saveAsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            saveFile.Filter = "Assembly Source File (*.asm)|*.asm|C# / CSharp Source File (*.cs)|*.cs|HTML-File (*.html)|*.html|JavaScript-File (*.js)|*.js|PostScript-File (*.ps)|*.ps|VBScript-File (*.vbs)|*.vbs|XML-File (*.xml)|*.xml|Ada Source File (*.ada)|*.ada|Windows-Batch-File (*.bat)|*.bat|CSS-File (*.css)|*.css|Ruby File (*.rb)|*.rb|Pascal Source File (*.pas)|*.pas|Perl Source File (*.pl)|*.pl|PHPScript-File (*.php)|*.php|Inno Setup Script (*.iss)|*.iss|Visual Basic Source File (*.vb)|*.vb|All Files (*.*)|*.*";
            if (saveFile.ShowDialog() == DialogResult.OK)
            {
                StreamWriter myWriterAs = new StreamWriter(saveFile.FileName);
                myWriterAs.Write(scintilla1.Text);
                myWriterAs.Close();
                this.Text = saveFile.FileName + " - ScriptZilla";
                newScriptToolStripMenuItem.Text = saveFile.FileName + " - ScriptZilla";
            }
        }

        private void printToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
        }

        private void endToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();

        }

        private void launchInScriptZillaLuaBrowserToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var luaBrw = new LuaBrowser();
            luaBrw.Show();

        }

        private void aboutScriptZillaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var about = new about();
            about.Show();

        }

        private void cCSharpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.ConfigurationManager.Language = "cs";
            toolStripStatusLabel2.Text = "C# / CSharp";

        }

        private void scriptCodecToolStripMenuItem_Click(object sender, EventArgs e)
        {
            
        }

        private void undoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.UndoRedo.Undo();

        }

        private void redoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            scintilla1.UndoRedo.Redo();

        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            //var xCan = new SaveByClose();
            //e.Cancel = true;
            //xCan.Show();
        }
        

        
    }
}
